
import fetch from 'node-fetch';
import fs from "fs"
import  * as iplib from "./findIpByIpaddressCom.mjs"

import {SimpleHosts} from 'simple-hosts/build/SimpleHosts.js'

async function main(){
    let content =  fs.readFileSync('hosts.conf','utf-8');
    let domains  = content.split('\n').map(v=>v.replace(/\s/g,'')).filter(v=>v.length > 0);

    let hosts = new SimpleHosts();
    for (let i = 0; i < domains.length; i++) {
        const domain = domains[i];
        let ip = await iplib.findIpByIpaddressCom(domain);

        if(ip){
            hosts.set(ip,domain);
        }
        console.log(domain, ip);
    }
}


main();